<?php
/**
 * 商铺业务逻辑类
 *
 * @author Alen
 * @since 1.0.0 2013-12-18 sutroon
 */
class SoBizShop extends SoBizBase {
    //put your code here
    public function __construct() {
        parent::__construct();
        $this->dm->tablename='tusermallshop';
    }
    
    /**
     * 读取商铺记录
     * @param type $uname
     * @return string
     * @since 1.0.0 2013-12-18 sutroon
     */
    public function read_one($uname){        
        $data=$this->dm->select_one_row('', "UserName='$uname'");
        if(!$data){
                $data=array('ShopName'=>'','Address'=>'','Contact'=>'','Telphone'=>'','HomePage'=>'','Logo'=>'','AboutUs'=>'');
                $this->dm->insert_record('','ShopName,Address,Contact,Telphone,HomePage,Logo,AboutUs,UserName',"'','','','','','','','$uname'");
        }
        return $data;
    }
    
    /**
     * 更新商店资料
     * @param type $uname
     * @param type $shopname
     * @param type $address
     * @param type $contact
     * @param type $telphone
     * @param type $homepage
     * @param type $logo
     * @param type $aboutus
     * @return type
     * @since 1.0.0 2013-12-18 sutroon
     */
    public function update_shop($uname,$shopname,$address,$contact,$telphone,$homepage,$logo,$aboutus){        
	$this->dm->add_param('ShopName',$shopname,'商铺名称未填写');
	$this->dm->add_param('Address',$address,'商家地址未填写');	
	$this->dm->add_param('Contact',$contact,'联系人未填写');	
	$this->dm->add_param('Telphone',$telphone,'电话号码未填写');
	$this->dm->add_param('AboutUs',$aboutus,'公司简介未填写');
        if($this->dm->has_error()) return $this->dm->get_error ();
        
	$this->dm->add_param('HomePage',$homepage);	
	$this->dm->add_param('Logo',$logo);	
        $msg=$this->dm->update("UserName='$uname'");
        return $msg=='SUCCESS'?$msg:$this->dm->get_error();
    }
}
